﻿using Frdp.Client.ScreenshotContainer.Factory.Duplicate;
using System;
using System.Drawing;
using System.IO;

namespace DesktopDuplication
{
    class Program
    {
        static void Main(string[] args)
        {
            DesktopDuplicator desktopDuplicator = new DesktopDuplicator(0);
            Bitmap bitmap = new Bitmap(1,1);
            // BUG: Sometimes it's a blank graph that requires continuous sampling
            for (int i = 0; i < 10; i++)
            {
                bitmap = desktopDuplicator.GetLatestFrame().DesktopImage;
            }
            desktopDuplicator.Dispose();
            const string outputFileName = "ScreenCapture.bmp";
            bitmap.Save(outputFileName);
            // Display the texture using system associated viewer
            System.Diagnostics.Process.Start(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, outputFileName)));
        }
    }
}
